Survival Analysis

Dr. F.J. Rodenburg
June 2024 (rev. 1)

Suppose...

A new cancer treatment is compared to an existing alternative.

  • Primary outcome: Patient survival

plot of chunk unnamed-chunk-2

plot of chunk unnamed-chunk-3

plot of chunk unnamed-chunk-42

Summary

Survival analysis is used to study time until event data.

  • Censoring and truncation;
  • Censored data can be accounted for using the Kaplan–Meijer estimator;
  • Survival curves can be compared with the log-rank test (a χ2-test);
  • Regression analysis can be done with Cox proportional hazards;
  • Censored and truncated data are possible in all kinds of research.

Summary

library("survival")
require("ggsurvfit")

# Fit a Kaplan-Meijer curve
KM <- survfit2(Surv(time, status) ~ sex, data = lung)                         

# Plot the result
ggsurvfit(KM) + labs(x = "Days", y = "Probability of survival") +
  add_risktable() + add_confidence_interval() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))

# Perform a log-rank test
survdiff(Surv(time, status) ~ sex, data = lung)

# Estimate survival at a given time (days)
summary(KM, times = 250)